<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AlterCouponOrderAddExtend extends Migrator
{
    public function up()
    {

        //为了扩展，mysql json 查询方式

        $sql  = <<<SQL

ALTER TABLE `coupon_order`

ADD COLUMN `ext_data`  json NULL COMMENT '扩展信息';

SQL;
        $this->execute($sql);


        $sql  = <<<SQL

ALTER TABLE `coupon_order`

ADD COLUMN `title`  varchar(50)NULL DEFAULT '' COMMENT '标题';

SQL;
        $this->execute($sql);
    }

    public function down()
    {
        $this->table('coupon_order')
            ->removeColumn('ext_data')
            ->removeColumn('title');
    }
}
